const Router = require('koa-router');
const router = new Router();

const Mock = require('mockjs'); //生成模拟数据

router.prefix('/demand')

router.get('/all/page', (ctx, next) => {

  const materialsDTOList = [];
  for (let i = 1; i < 7; i++) {
    materialsDTOList.push({
      matId: '4asd4ad' + i,
      extendId: '',
      type: i + '', //(1-海报,2-视频,3-DM单页,4-九宫格,5-h5链接,6-展架)
      titleOne: '农夫山泉出新包装啦！快来试喝！1农夫山泉出新包装啦！快来试喝！1',
      titleTwo: '农夫山泉出新包装啦！新品来袭！快来试喝！2新包装啦！新品来袭！快来试喝！2',
      festival: 1,
      degree: 1054121,
      isCollect: '0',
      imagesDTOList: [{
        'imageUrl': 'http://192.168.20.184:8083/test/123.jpg',
        'type': "1"
      }, {
        'imageUrl': 'http://192.168.20.184:8083/test/123.png',
        'type': "2"
      }, {
        'imageUrl': 'http://192.168.20.184:8083/test/153.png',
        'type': "3"
      }, {
        'imageUrl': 'http://192.168.20.184:8083/test/12345.png',
        'type': "4"
      }, {
        'imageUrl': 'http://192.168.20.184:8083/test/123.jpg',
        'type': "5"
      }, {
        'imageUrl': 'http://192.168.20.184:8083/test/123.jpg',
        'type': "6"
      }]
    });
  }

  const records = [];
  for (let i = 1; i < 7; i++) {
    records.push({
      demId: 'asdasd' + i,
      name: "玩哈哈纯净水" + i,
      brand: "品牌",
      materialsDTOList: materialsDTOList
    });
  }
  ctx.body = tools.stateJson({
    code: 200,
    records: records
  })
});



router.get('/page', (ctx, next) => {
  const param = ctx.query;
  const records = [];
  const total = tools.randomRange(30, 31);
  for (let i = 0; i < total; i++) {
    records.push({
      "extendId": "dolore",
      "images": [],
      "createTime": "1986-04-10",
      "updateTime": "1991-03-28",
      "type": Mock.Random.range(1, 6) + "",
      "stage": param.stage,
      "brand": "consequat irure ut adipisicing",
      "demId": Mock.Random.string(10),
      "name": Mock.Random.cname() + i + ',' + total,
      "images": ['http://192.168.20.184:8083/test/123.jpg']
    });
  }

  ctx.body = tools.stateJson({
    code: 200,
    total: total + 30,
    records: records
  })
});



module.exports = router;
